package cn.liyicun.cp.cpweb.service;

import cn.liyicun.cp.cpweb.base.YesNoEnum;
import cn.liyicun.cp.cpweb.mapper.MoneyRechargeMapper;
import cn.liyicun.cp.cpweb.service.money.IMoneyLog;
import cn.liyicun.cp.cpweb.service.money.MoneyTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Service
public class MoneyService {

    @Autowired
    private MoneyRechargeMapper moneyRechargeMapper;

    public void ext(HttpServletRequest request, String type, Long id, String status, String remark, Object param) {
        WebApplicationContext webApplicationContext = WebApplicationContextUtils
                .getWebApplicationContext(request.getServletContext());
        Map<String, IMoneyLog> maps = webApplicationContext.getBeansOfType(IMoneyLog.class);
        for (Map.Entry<String, IMoneyLog> data : maps.entrySet()) {

            boolean flag = data.getValue().ext(MoneyTypeEnum.valueOf(type), id, YesNoEnum.valueOf(status), remark, param);
            if (flag) {
                break;
            }
        }
    }
}
